/* ==========================================================================
   SD WebUI Forge Neo - Turbo Optimizer
   Zero-Conflict GPU Acceleration, CSS Layout Containment & Clean UI Layout
   ========================================================================== */

/* 1. DOM Isolation & Tab Layout Containment (Zero recalculation for inactive tabs) */
#tabs > .tabitem[style*="display: none"],
.tabitem.hidden,
div[id$="_extra_tabs"] > .tabitem[style*="display: none"] {
    content-visibility: auto !important;
    contain: strict !important;
    pointer-events: none !important;
}

/* 2. Extra Networks Card Grid Containment (Layout & Style containment without clipping tooltips) */
.extra-network-cards,
.extra-network-pane {
    contain: layout style !important;
    transform: translateZ(0);
}

/* Ensure hover bubbles and tooltips from sd-forge-card-hover-names & Civitai Helper are never clipped */
.extra-network-cards .card,
.extra-network-pane .card,
.standalone-card-preview.card {
    contain: style !important;
    will-change: transform;
    transform: translateZ(0);
}

/* 3. Hardware Acceleration for High-Frequency Interactive Controls */
.gradio-slider input[type="range"] {
    will-change: transform;
    transform: translateZ(0);
}

/* 4. Asynchronous Image Decoding & Hardware Accelerated Galleries */
#txt2img_gallery img,
#img2img_gallery img,
.gradio-gallery img,
.livePreview img {
    decoding: async !important;
    image-rendering: -webkit-optimize-contrast;
    will-change: transform;
    transform: translateZ(0);
}

/* 5. Autocomplete & Floating Menu Safe-Zone (TagComplete-Neo & Fluid UI compatibility) */
.autocompleteResults,
.fluid-drawer-overlay,
.fluid-bento-card,
.fluid-cockpit-grid {
    contain: none !important;
}

/* 6. Enforce Clean UI: Hide all floating "Flush RAM" and overlay helper buttons */
#mobile-flush-ram-btn,
#turbo-optimizer-hud,
.floating-flush-ram,
button[id*="flush-ram"],
button[id*="flush_ram"],
button[id*="mobile-flush"] {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
    z-index: -9999 !important;
}

/* 7. Strict Protection: Keep all Generate buttons fully visible, prioritized & unobstructed */
#txt2img_generate,
#img2img_generate,
button[id$="_generate"],
.generate-button,
.gr-button-primary[id*="generate"] {
    display: inline-block !important;
    visibility: visible !important;
    pointer-events: auto !important;
    opacity: 1 !important;
}
